import {Component, Input, OnInit} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {ApiService} from "@core/services/api";
import {SPage} from "@shared/components/table-page/table-page.component";
import * as moment from 'moment'

@Component({
  selector: 'app-room-detail',
  templateUrl: './room-detail.component.html',
  styles: []
})
export class RoomDetailComponent implements OnInit {
  @Input() data: any;
  roomType = {
    '1': '出租',
    '2': '旅店',
    '3': '办公室',
    '4': '店面',
  }
  config: SPage = {
    columns: [

      {
        index: 'infoName',
        title: '用户名',
      },
      {
        index: 'infoSex',
        title: '性别',
        filter: {
          type: 'select',
          hideSearch: true,
          items: [
            {label: '男', value:'1'},
            {label: '女', value:'0'},
            {label: '未说明的性别', value: '9'},
          ],
        },
      },
      // {
      //   index: 'infoAge',
      //   title: '年龄',
      // },
      /*{
        index: 'houseAddress',
        title: '房屋地址',
        filter: {
          type: 'string'
        }
      },*/
      {
        index: 'infoBirthday',
        title: '出生日期',
        fFn:(item)=>{
          return moment(item.infoBirthday).format('yyyy-MM-DD');
        }
      },
      {
        index: 'infoNationName',
        title: '民族',
      },
      {
        index: 'infoMobile',
        title: '联系电话',
      },
      /*{
        index: 'infoSex',
        title: '性别',
        filter: {
          type: 'select',
          items: [
            {label: '男', value:'1'},
            {label: '女', value:'2'},
            {label: '未知', value: '0'},
            {label: '店面', value: '4'}
          ]
        }
      },
      {
        index: 'status',
        title: '状态',
        type: ColumnType.tag,
        tag: {
          false: {text:'停用', color: 'red'},
          true: {text:'启用', color: 'green'},
        },
        filter: {
          type: 'select',
          items: [
            {label: '启用', value: true},
            {label: '停用', value: false},
          ]
        }
      },*/
      /*{
        index: 'houseRemark',
        title: '备注'
      },*/
    ],
    data: [],
    editBtn: [
    ],
    ps: 5,
  };
  constructor(
    private http: HttpClient,
    private api: ApiService
  ) { }

  ngOnInit() {
    this.http.post(this.api.room.getInfoById.url, {id:this.data.id}).subscribe((res:any) => {
      if (res && res.status == '200') {
        this.config.data = res.data;
      }
    })
  }

}
